﻿Public Class clsInhPozycjaZlecenia
    Inherits clsPozycjeZlecenia

#Region "Attributes"

    Private mvarMaterialOgolnie As clsGatunek
    Private mvarJednostka As clsJednostkaMiary
    Private mvarWaluta As clsWaluta
    Private mvarPakowanie As clsPakowanie
    Private mvarMagazyn As clsMagazyn

#End Region

#Region "Properties"

    Public Property MaterialOgolnie As clsGatunek
        Get
            Return mvarMaterialOgolnie
        End Get
        Set(ByVal value As clsGatunek)
            mvarMaterialOgolnie = value
        End Set
    End Property

    Public Property Jednostka As clsJednostkaMiary
        Get
            Return mvarJednostka
        End Get
        Set(ByVal value As clsJednostkaMiary)
            mvarJednostka = value
        End Set
    End Property

    Public Property Waluta As clsWaluta
        Get
            Return mvarWaluta
        End Get
        Set(ByVal value As clsWaluta)
            mvarWaluta = value
        End Set
    End Property

    Public Property Pakowaie As clsPakowanie
        Get
            Return mvarPakowanie
        End Get
        Set(ByVal value As clsPakowanie)
            mvarPakowanie = value
        End Set
    End Property

    Public Property Magazyn As clsMagazyn
        Get
            Return mvarMagazyn
        End Get
        Set(ByVal value As clsMagazyn)
            mvarMagazyn = value
        End Set
    End Property

#End Region

#Region "Methods"

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal ID As Integer, ByVal lvarDbHolder As clsDataBase)

        MyBase.New(ID, lvarDbHolder, VAR_ERROR_HANDLER)

        mvarJednostka = New clsJednostkaMiary(MyBase.JednostkaMiaryId, lvarDbHolder, VAR_ERROR_HANDLER)
        mvarMaterialOgolnie = New clsGatunek(MyBase.GatunekId, lvarDbHolder, VAR_ERROR_HANDLER)
        mvarWaluta = New clsWaluta(MyBase.WalutaId.ToString(), lvarDbHolder, VAR_ERROR_HANDLER)
        mvarPakowanie = New clsPakowanie(MyBase.PakowaniaId.ToString(), lvarDbHolder, VAR_ERROR_HANDLER)
        mvarMagazyn = New clsMagazyn(MyBase.MagazynId, lvarDbHolder, VAR_ERROR_HANDLER)

    End Sub

    Public Overloads Sub Save(ByVal lvarDbHolder As clsDataBase)

        MyBase.Save(lvarDbHolder, VAR_ERROR_HANDLER)

    End Sub

    Public Overloads Sub Delete(ByVal lvarDbHolder As clsDataBase)

        MyBase.Delete(lvarDbHolder, VAR_ERROR_HANDLER)

    End Sub

    Shared Function ZmienStatus(ByVal lvarDbHolder As clsDataBase, IdZleceniaPozycji As Integer, IdStatus As Integer) As Boolean

        Dim lvarReader As OdbcDataReader = Nothing
        Dim lvarReturn As Boolean

        If lvarDbHolder.IsOpen Then
            Dim lvarSqlRunner As New clsSqlRunner(lvarDbHolder, "queries_application_tracking", "cls_pozycjie_zlecenia", 3, VAR_ERROR_HANDLER)
            '      

            With lvarSqlRunner
                .AddParameter("p_pozycja_zlecenia_id", IdZleceniaPozycji.ToString())
                .AddParameter("p_status_id", IdStatus.ToString())
                lvarReader = .ExecuteQuery
            End With

        End If

        Return lvarReturn

    End Function

#End Region

End Class
